home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 40
/
Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso
/
Aminet
/
misc
/
emu
/
ATUtilities.lha
/
ATUtilities
/
ARexx.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-09-26
|
25KB
|
1,014 lines
/* ******************************************************************* */
/* ** ** */
/* ** ATKeyboard Version 4.0 ** */
/* ** Copright (C) 1992-1994 by Thomas Dreibholz ** */
/* ** All rights reserved ** */
/* ** ** */
/* ** ARexx-Verwaltung ** */
/* ** ** */
/* ******************************************************************* */
#include "ATKeyboard.h"
#include "ATUtilities.h"
#define xRMBTRAP (0xffffffff-RMBTRAP)
extern struct Einstellungen Einstellungen;
extern struct Einstellungen *Prefs;
UBYTE PrefsOK;
struct FileHandle *RWindow;
struct RexxMsg *rexx;
BOOL output;
UBYTE *Titel,*MLTitel;
UBYTE ARexxTitel[70];
extern struct Process *MainTask;
extern struct Window *WindowPtr;
extern struct Menu Menu1;
extern struct ExecBase *SysBase;
extern struct IOClipReq *ClipReq;
EXTERN UBYTE *TitelText,Drucker,Papier,Cache;
EXTERN UBYTE *PapierStat[],*DruckerStat[],*CacheStat[];
EXTERN UBYTE ATKeyboardVersion,ATKeyboardRevision;
EXTERN LONG KickstartVersion;
EXTERN LONG ClipDev;
EXTERN ULONG transfer;
EXTERN BOOL Online,LPT1,Service,Clock;
EXTERN BOOL Schoner;
EXTERN UBYTE MKAuf[];
EXTERN UBYTE MKZu[];
EXTERN UBYTE IKAuf[];
EXTERN UBYTE IKZu[];
EXTERN UBYTE ARexxLock;
EXTERN UBYTE ARexxMenuLock;
EXTERN UBYTE *HiFiPort;
VOID RW();
VOID OW();
VOID SendeZeichen();
VOID SendeDatei();
VOID SendeClip();
/* ARexx-Befehlsverarbeitung */
VOID HandleRexxMsg(rm,bool)
struct RexxMsg *rm;
BOOL bool;
{
REGISTER UBYTE *t;
REGISTER LONG Res1,Res2;
REGISTER LONG i,j,CmdCount,Pos;
UBYTE Command[10][50];
UBYTE buffer[24];
UBYTE c;
register struct FileHandle *fh;
rexx=rm;
output=bool;
Titel=NULL;
Pos=0;
for(i=0,CmdCount=0;i<strlen(rexx->rm_Args[0]);i++)
{
c=rexx->rm_Args[0][i];
if(c==' ')
{
Command[CmdCount++][Pos]=0x00;
Pos=0;
if(CmdCount>9) break;
}
else
{
if(Pos<49) Command[CmdCount][Pos++]=toupper(c);
}
}
Command[CmdCount++][Pos]=0x00;
for(i=CmdCount;i<10;i++) *Command[i]=0;
Res1=0;
Res2=0;
if(!(strncmp(&Command[0],"INFO",4)))
{
ShowInformation(FALSE);
}
if(!(strncmp(&Command[0],"SAVEPREFS",9)))
{
PrefsOK=1;
CopyMem(&Einstellungen,Prefs,sizeof(struct Einstellungen));
}
if(!(strncmp(&Command[0],"LOADPREFS",9)))
{
if(PrefsOK==1)
{
CopyMem(Prefs,&Einstellungen,sizeof(struct Einstellungen));
ZeigeEinstellungen(TRUE);
}
else
{
OW(60,"loadprefs");
RW("FEHLER: Einstellungen wurden vorher nicht\n");
RW(" mit \"saveprefs\" gesichert.");
}
}
else if(!(strncmp(&Command[0],"ONLINE",6)))
{
if(Online==FALSE)
{
XLine(TRUE);
}
}
else if(!(strncmp(&Command[0],"OFFLINE",7)))
{
if(Online==TRUE)
{
XLine(FALSE);
}
}
else if(!(strncmp(&Command[0],"VERSION",7)))
{
OW(50,"version");
RW(Copyright[0]);
RW("\n");
}
else if(!(strncmp(&Command[0],"PCWRITEFILE",11)))
{
if(Online!=FALSE)
{
if(!(*Command[1]==0))
{
fh=Open(&Command[1],MODE_OLDFILE);
if(fh!=NULL)
{
SendeDatei(fh);
Close(fh);
}
else
{
Res1=10;
Res2=1;
OW(60,"pcwritefile");
RW("FEHLER: Die angegebene Datei konnte nicht\n");
RW(" geöffnet werden.\n");
}
}
else
{
Res1=10;
Res2=1;
OW(60,"pcwritefile");
RW("FEHLER: Fehlendes Argument.\n");
RW(" Syntax: pcwritefile [Dateiname]\n");
}
}
else
{
OW(60,"pcwritefile");
RW("FEHLER: Zum Übertragen muß ATKeyboard auf\n");
RW(" \"Online\" gesetzt sein.\n");
}
}
else if(!(strncmp(&Command[0],"SENDCLIPBOARD",13)))
{
if(Online!=FALSE)
{
if(ClipDev==0)
{
SendeClip();
}
else
{
OW(60,"sendclipboard");
RW("FEHLER: Clipboard-Device konnte beim Start von");
RW(" ATKeyboard nicht geladen werden!");
}
}
else
{
OW(60,"sendclipboard");
RW("FEHLER: Zum Übertragen muß ATKeyboard auf\n");
RW(" \"Online\" gesetzt sein.\n");
}
}
else if(!(strncmp(&Command[0],"GETVERSION",10)))
Res1=ATKeyboardVersion;
else if(!(strncmp(&Command[0],"GETREVISION",11)))
Res1=ATKeyboardRevision;
else if(!(strncmp(&Command[0],"GETSPEED",8)))
Res1=Einstellungen.Uebertragungsrate;
else if(!(strncmp(&Command[0],"GETPRI",6)))
Res1=Einstellungen.Prioritaet;
else if(!(strncmp(&Command[0],"LOCK",4)))
ARexxLock=1;
else if(!(strncmp(&Command[0],"UNLOCK",6)))
ARexxLock=0;
else if(!(strncmp(&Command[0],"MENULOCK",8)))
{
if(MLTitel==NULL)
{
MLTitel=WindowPtr->Title;
WindowPtr->Flags |= RMBTRAP;
SetWindowTitles(WindowPtr,"ATKeyboard - ARexx Menüsperre aktiv!",-1L);
}
}
else if(!(strncmp(&Command[0],"MENUUNLOCK",10)))
{
WindowPtr->Flags &= xRMBTRAP;
if(MLTitel!=NULL)
{
SetWindowTitles(WindowPtr,MLTitel,-1L);
MLTitel=NULL;
}
}
else if(!(strncmp(&Command[0],"PCWRITE",7)))
{
if(Online==TRUE)
{
if(!(*Command[1]==0))
{
i=atol(&Command[1]);
if((i<0)||(i>255))
{
Res1=10;
Res2=1;
OW(60,"pcwrite");
RW("FEHLER: Falscher Code.\n");
RW(" Code muß im Bereich von 0 bis 255 liegen.\n");
}
else
{
Taste(i,0);
}
}
else
{
Res1=10;
Res2=1;
OW(60,"pcwrite");
RW("FEHLER: Fehlendes Argument.\n");
RW(" Syntax: pcwrite [Rawkey-Code]\n");
}
}
}
else if(!(strncmp(&Command[0],"LPT1",4)))
{
if(!(*Command[1]==0))
{
if(!(strncmp(&Command[1],"ON",2)))
{
LPT1=TRUE;
KontrolliereLPT1();
}
else if(!(strncmp(&Command[1],"OFF",3)))
{
LPT1=FALSE;
KontrolliereLPT1();
}
else if(!(strncmp(&Command[1],"RESET",5)))
{
Druckerreset();
}
else if(!(strncmp(&Command[1],"INFO",4)))
{
if(LPT1==TRUE)
{
OW(80,"LPT1");
sprintf(&buffer,"%8ld",transfer);
RW("Transfer: "); RW(&buffer);
RW(" Bytes\nCache: "); RW(CacheStat[Cache]);
RW("\nPapier: "); RW(PapierStat[Papier]);
RW("\nDrucker: "); RW(DruckerStat[Drucker]); RW("\n");
}
else
{
OW(50,"LPT1");
RW("Die LPT1-Verwaltung ist ausgeschaltet.\n");
}
}
else
{
OW(60,"LPT1");
RW("FEHLER: Falsches Argument.\n");
RW(" Syntax: LPT1 {on|off|reset|info}\n");
}
}
else
{
OW(50,"LPT1");
if(LPT1==TRUE)
{
RW("Die LPT1-Verwaltung ist eingeschaltet.\n");
}
else
{
RW("Die LPT1-Verwaltung ist ausgeschaltet.\n");
}
}
}
else if(!(strncmp(&Command[0],"TIMESERV",8)))
{
if(!(*Command[1]==0))
{
if(!(strncmp(&Command[1],"ON",2)))
{
Service=TRUE;
KontrolliereService();
}
else if(!(strncmp(&Command[1],"OFF",3)))
{
Service=FALSE;
KontrolliereService();
}
else if(!(strncmp(&Command[1],"INFO",4)))
{
OW(50,"timeserv");
if(Service==TRUE)
RW("TimeService ist eingeschaltet.");
else
RW("TimeService ist ausgeschaltet.");
}
}
else
{
OW(60,"timeserv");
RW("FEHLER: Falsches Argument.\n");
RW(" Syntax: timeserv [on|off|info]\n");
}
}
else if(!(strncmp(&Command[0],"CLOCK",5)))
{
if(!(*Command[1]==0))
{
if(!(strncmp(&Command[1],"ON",2)))
{
Clock=TRUE;
KontrolliereUhr();
}
else if(!(strncmp(&Command[1],"OFF",3)))
{
Clock=FALSE;
KontrolliereUhr();
}
}
else
{
OW(60,"clock");
RW("FEHLER: Falsches Argument.\n");
RW(" Syntax: clock [on|off]\n");
}
}
else if(!(strncmp(&Command[0],"KEYFILTER",9)))
{
if(!(*Command[1]==0))
{
if(!(strncmp(&Command[1],"ON",2)))
Einstellungen.Tastenfilter=YES;
if(!(strncmp(&Command[1],"OFF",2)))
Einstellungen.Tastenfilter=NO;
ZeigeEinstellungen(TRUE);
}
else
{
OW(60,"keyfilter");
RW("FEHLER: Falsches Argument.\n");
RW(" Syntax: keyfilter [on|off]\n");
}
}
else if(!(strncmp(&Command[0],"KEYREPEAT",9)))
{
if(!(*Command[1]==0))
{
if(!(strncmp(&Command[1],"ON",2)))
Einstellungen.Tastenwiederholung=YES;
if(!(strncmp(&Command[1],"OFF",2)))
Einstellungen.Tastenwiederholung=NO;
ZeigeEinstellungen(TRUE);
}
else
{
OW(60,"keyrepeat");
RW("FEHLER: Falsches Argument.\n");
RW(" Syntax: keyrepeat [on|off]\n");
}
}
else if(!(strncmp(&Command[0],"KEYUP",5)))
{
if(!(*Command[1]==0))
{
if(!(strncmp(&Command[1],"ON",2)))
Einstellungen.Tastenruecknahme=YES;
if(!(strncmp(&Command[1],"OFF",2)))
Einstellungen.Tastenruecknahme=NO;
ZeigeEinstellungen(TRUE);
}
else
{
OW(60,"keyup");
RW("FEHLER: Falsches Argument.\n");
RW(" Syntax: keyup [on|off]\n");
}
}
else if(!(strncmp(&Command[0],"INTWAIT",7)))
{
if(!(*Command[1]==0))
{
if(!(strncmp(&Command[1],"ON",2)))
Einstellungen.WarteAufInt=YES;
if(!(strncmp(&Command[1],"OFF",2)))
Einstellungen.WarteAufInt=NO;
ZeigeEinstellungen(TRUE);
}
else
{
OW(60,"intwait");
RW("FEHLER: Falsches Argument.\n");
RW(" Syntax: intwait [on|off]\n");
}
}
else if(!(strncmp(&Command[0],"SETSPEED",8)))
{
if(!(*Command[1]==0))
{
i=atol(&Command[1]);
if(i>150) i=150;
if(i<0) i=0;
Einstellungen.Uebertragungsrate=i;
}
else
{
OW(60,"setspeed");
RW("FEHLER: Falsches Argument.\n");
RW(" Syntax: setspeed [0..150]\n");
}
}
else if(!(strncmp(&Command[0],"SETPRI",6)))
{
if(!(*Command[1]==0))
{
i=atol(&Command[1]);
if(i>127) i=127;
if(i<-128) i=-128;
Einstellungen.Prioritaet=i;
SetTaskPri(MainTask,i);
}
else
{
OW(60,"setpri");
RW("FEHLER: Falsches Argument.\n");
RW(" Syntax: setpri [-128..127]\n");
}
}
else if(!(strncmp(&Command[0],"BLANKER",7)))
{
if(!(*Command[1]==0))
{
if(!(strncmp(&Command[1],"ON",2)))
{
Schoner=TRUE;
KontrolliereSchoner();
}
else if(!(strncmp(&Command[1],"OFF",3)))
{
Schoner=FALSE;
KontrolliereSchoner();
}
else
{
OW(60,"blanker");
RW("FEHLER: Falsches Argument.\n");
RW(" Syntax: blanker {on|off}\n");
}
}
else
{
if(Schoner==TRUE)
{
RW("Der Schoner ist eingeschaltet.\n");
}
else
{
RW("Der Schoner ist ausgeschaltet.\n");
}
}
}
else if(!(strncmp(&Command[0],"PLAYER",6)))
{
if(!(*Command[1]==0))
{
bool=TRUE;
if(!(strncmp(&Command[1],"PLAY",4)))
bool=UtilityQuiet(HiFiPort,1001);
else if(!(strncmp(&Command[1],"STOP",4)))
bool=UtilityQuiet(HiFiPort,1002);
else if(!(strncmp(&Command[1],"FIRST",5)))
bool=UtilityQuiet(HiFiPort,1003);
else if(!(strncmp(&Command[1],"LAST",4)))
bool=UtilityQuiet(HiFiPort,1004);
else if(!(strncmp(&Command[1],"NEXT",4)))
bool=UtilityQuiet(HiFiPort,1005);
else if(!(strncmp(&Command[1],"PREV",4)))
bool=UtilityQuiet(HiFiPort,1006);
else if(!(strncmp(&Command[1],"RND",3)))
bool=UtilityQuiet(HiFiPort,1500);
else if(!(strncmp(&Command[1],"QUIT",4)))
bool=UtilityQuiet(HiFiPort,UTILITY_QUIT);
else if(!(strncmp(&Command[1],"VOL+",4)))
bool=UtilityQuiet(HiFiPort,1013);
else if(!(strncmp(&Command[1],"VOL-",4)))
bool=UtilityQuiet(HiFiPort,1014);
else if(!(strncmp(&Command[1],"LOAD",4)))
bool=UtilityQuiet(HiFiPort,1008);
else if(!(strncmp(&Command[1],"SAVE",4)))
bool=UtilityQuiet(HiFiPort,1009);
else if(!(strncmp(&Command[1],"EDIT",4)))
bool=UtilityQuiet(HiFiPort,1007);
else if(!(strncmp(&Command[1],"DISPLAY",7)))
bool=UtilityQuiet(HiFiPort,1012);
else
{
Res1=10;
Res2=1;
OW(70,"player");
RW("FEHLER: Unbekanntes Argument.\n");
RW(" Argumente: play stop first last next prev\n");
RW(" vol+ vol- rnd edit load save\n");
RW(" display\n");
}
if(bool==FALSE)
{
Res1=10;
Res2=1;
OW(60,"player");
RW("FEHLER: HiFi-Player ist nicht aktiv.\n");
RW(" Starten Sie zuerst das Programm!\n");
}
}
else
{
Res1=10;
Res2=1;
OW(70,"player");
RW("FEHLER: Falsches Argument.\n");
RW(" Argumente: play stop first last next prev\n");
RW(" vol+ vol- rnd edit load save\n");
RW(" display\n");
}
}
else if(!(strncmp(&Command[0],"UTILITYQUIET",12)))
{
if(!(*Command[1]==0))
{
if((*Command[2]==0))
{
UtilityQuiet(&Command[1],UTILITY_CALL);
}
else
{
UtilityQuiet(&Command[1],atol(&Command[2]));
}
}
else
{
Res1=10;
Res2=1;
OW(60,"utilityquiet");
RW("FEHLER: Falsches Argument.\n");
RW(" Syntax: utility [Portname] {Kommando}\n");
}
}
else if(!(strncmp(&Command[0],"UTILITY",7)))
{
if(!(*Command[1]==0))
{
if((*Command[2]==0))
{
CallUtility(&Command[1]);
}
else
{
Utility(&Command[1],atol(&Command[2]));
}
}
else
{
Res1=10;
Res2=1;
OW(60,"utility");
RW("FEHLER: Falsches Argument.\n");
RW(" Syntax: utility [Portname] {Kommando}\n");
}
}
else if(!(strncmp(&Command[0],"DATACACHE",9)))
{
if(KickstartVersion>=36)
{
if(SysBase->AttnFlags & AFF_68030)
{
if(!(*Command[1]==0))
{
if(!(strncmp(&Command[1],"ON",2)))
{
CacheControl(CACRF_EnableD,CACRF_EnableD|CACRF_FreezeD);
}
else if(!(strncmp(&Command[1],"OFF",3)))
{
CacheControl(CACRF_FreezeD,CACRF_EnableD|CACRF_FreezeD);
}
else
{
Res1=10;
Res2=1;
OW(60,"datacache");
RW("FEHLER: Falsches Argument.\n");
RW(" Syntax: datacache {on|off}\n");
}
}
else
{
i=CacheControl(0,0);
t="Der Datencache ist ausgeschaltet";
if(i & CACRF_EnableD) t="Der Datencache ist eingeschaltet";
if((i & CACRF_EnableD)&&(i & CACRF_DBE)) t="Der Datencache ist im Burst-Modus";
OW(60,"datacache");
RW("Aktueller Status des Datencaches:\n ");
RW(t);
RW("\n");
}
}
else
{
Res1=10;
Res2=1;
OW(60,"datacache");
RW("FEHLER: \"datacache\" ist erst bei 68030-Systemen verfügbar!\n");
}
}
else
{
Res1=10;
Res2=1;
OW(60,"datacache");
RW("FEHLER: \"datacache\" ist erst ab Kickstart\n");
RW(" Version 2.0 verfügbar!\n");
}
}
else if(!(strncmp(&Command[0],"HELP",4)))
{
OW(170,"help");
RW("ATKeyboard hält für Sie folgende Befehle bereit:\n");
RW(" - help\n");
RW(" - info\n");
RW(" - quit\n");
RW(" - online\n");
RW(" - offline\n");
RW(" - version\n");
RW(" - LPT1 {on|off|reset|info}\n");
RW(" - blanker {on|off}\n");
RW(" - datacache {on|off}\n");
RW(" - pcwrite [Rawkey-Code]\n");
RW(" - pcwritefile [Dateiname]\n");
RW(" - utility [Portname]\n");
RW(" - player [play|stop|first|last|next|prev|rnd\n");
RW(" load|save|edit|vol+|vol-|display]\n");
}
else if(!(strncmp(&Command[0],"QUIT",4)))
{
rexx->rm_Result1=0;
rexx->rm_Result2=0;
ReplyMsg(rexx);
CloseAll();
}
else
{
Res1=10;
Res2=1;
OW(50,"?");
RW("FEHLER: Unbekanntes Kommando. Hilfe mit \"help\".\n");
}
rexx->rm_Result1=Res1;
rexx->rm_Result2=Res2;
ReplyMsg(rexx);
if(RWindow!=NULL)
{
RW("\n<< Taste >>\n");
Read(RWindow,&c,1);
Close(RWindow);
RWindow=NULL;
}
if(Titel!=NULL)
{
SetMenuStrip(WindowPtr,&Menu1);
SetWindowTitles(WindowPtr,Titel,TitelText);
}
}
/* Text in ARexx-Fenster schreiben */
VOID RW(text)
UBYTE *text;
{
if(RWindow)
{
Write(RWindow,text,strlen(text));
}
else
{
if(rexx->rm_Stdout) Write(rexx->rm_Stdout,text,strlen(text));
}
}
/* ARexx-Ausgabe öffnen */
VOID OW(ySize,cmd)
LONG ySize;
UBYTE *cmd;
{
REGISTER UWORD top;
REGISTER UBYTE c;
UBYTE buffer[70];
RWindow=NULL;
top=(200-ySize)/2;
if((output==FALSE)||(rexx->rm_Stdout==NULL))
{
ClearMenuStrip(WindowPtr);
Titel=WindowPtr->Title;
sprintf(&ARexxTitel,"ATKeyboard - ARexx \"%s\"",cmd);
SetWindowTitles(WindowPtr,&ARexxTitel,TitelText);
if(KickstartVersion>=36) c='/'; else c=0x00;
sprintf(&buffer,"CON:75/%ld/450/%ld/ATKeyboard - ARexx \"%s\"%cCLOSE",top,ySize,cmd,c);
RWindow=Open(&buffer,MODE_READWRITE);
}
}
/* ASCII-Zeichen an PC senden */
#define NORMAL 0
#define SHIFT (1L<<1)
#define BIT7 (1L<<7)
struct Tabelle
{
UBYTE Zeichen;
UBYTE RawCode;
UBYTE Flags;
};
struct Tabelle T[]=
{
{0x0A,0x44,NORMAL},
{' ',0x40,NORMAL},
{'1',0x01,NORMAL}, {'2',0x02,NORMAL}, {'3',0x03,NORMAL}, {'4',0x04,NORMAL},
{'5',0x05,NORMAL}, {'6',0x06,NORMAL}, {'7',0x07,NORMAL}, {'8',0x08,NORMAL},
{'9',0x09,NORMAL}, {'0',0x0A,NORMAL}, {'ß',0x0B,NORMAL}, {'\\',0x0D,NORMAL},
{'q',0x10,NORMAL}, {'w',0x11,NORMAL}, {'e',0x12,NORMAL}, {'r',0x13,NORMAL},
{'t',0x14,NORMAL}, {'z',0x15,NORMAL}, {'u',0x16,NORMAL}, {'i',0x17,NORMAL},
{'o',0x18,NORMAL}, {'p',0x19,NORMAL}, {'ü',0x1A,NORMAL}, {'+',0x1B,NORMAL},
{'a',0x20,NORMAL}, {'s',0x21,NORMAL}, {'d',0x22,NORMAL}, {'f',0x23,NORMAL},
{'g',0x24,NORMAL}, {'h',0x25,NORMAL}, {'j',0x26,NORMAL}, {'k',0x27,NORMAL},
{'l',0x28,NORMAL}, {'ö',0x29,NORMAL}, {'ä',0x2A,NORMAL}, {'#',0x2B,NORMAL},
{'<',0x30,NORMAL}, {'y',0x31,NORMAL}, {'x',0x32,NORMAL}, {'c',0x33,NORMAL},
{'v',0x34,NORMAL}, {'b',0x35,NORMAL}, {'n',0x36,NORMAL}, {'m',0x37,NORMAL},
{',',0x38,NORMAL}, {'.',0x39,NORMAL}, {'-',0x3A,NORMAL},
{'!',0x01,SHIFT}, {'\"',0x02,SHIFT}, {'§',0x03,SHIFT}, {'$',0x04,SHIFT},
{'%',0x05,SHIFT}, {'&',0x06,SHIFT}, {'/',0x07,SHIFT}, {'(',0x08,SHIFT},
{')',0x09,SHIFT}, {'=',0x0A,SHIFT}, {'?',0x0B,SHIFT}, {'|',0x0D,SHIFT},
{'Q',0x10,SHIFT}, {'W',0x11,SHIFT}, {'E',0x12,SHIFT}, {'R',0x13,SHIFT},
{'T',0x14,SHIFT}, {'Z',0x15,SHIFT}, {'U',0x16,SHIFT}, {'I',0x17,SHIFT},
{'O',0x18,SHIFT}, {'P',0x19,SHIFT}, {'Ü',0x1A,SHIFT}, {'*',0x1B,SHIFT},
{'A',0x20,SHIFT}, {'S',0x21,SHIFT}, {'D',0x22,SHIFT}, {'F',0x23,SHIFT},
{'G',0x24,SHIFT}, {'H',0x25,SHIFT}, {'J',0x26,SHIFT}, {'K',0x27,SHIFT},
{'L',0x28,SHIFT}, {'Ö',0x29,SHIFT}, {'Ä',0x2A,SHIFT}, {'^',0x2B,SHIFT},
{'>',0x30,SHIFT}, {'Y',0x31,SHIFT}, {'X',0x32,SHIFT}, {'C',0x33,SHIFT},
{'V',0x34,SHIFT}, {'B',0x35,SHIFT}, {'N',0x36,SHIFT}, {'M',0x37,SHIFT},
{';',0x38,SHIFT}, {':',0x39,SHIFT}, {'_',0x3A,SHIFT},
{0xFF,0xFF,0xFF}
};
VOID SendeZeichen(chr)
UBYTE chr;
{
REGISTER UBYTE Flags;
REGISTER UBYTE RawCode;
REGISTER WORD i;
switch(chr)
{
case '{':
Tastenkombination(&MKAuf);
break;
case '}':
Tastenkombination(&MKZu);
break;
case '[':
Tastenkombination(&IKAuf);
break;
case ']':
Tastenkombination(&IKZu);
break;
default:
RawCode=10000;
for(i=0;i<10000;i++)
{
if(T[i].Zeichen==chr)
{
RawCode=T[i].RawCode;
Flags=T[i].Flags;
i=10000;
}
else if(T[i].Flags==0xFF) i=10000;
}
if(RawCode!=10000)
{
if(Flags & SHIFT) Taste(0x60,0);
Taste(RawCode,0);
Taste(RawCode|BIT7,0);
if(Flags & SHIFT) Taste(0x60|BIT7,0);
}
break;
}
}
/* Zeichen aus ASCII-Datei an PC senden */
VOID SendeDatei(fh)
struct FileHandle *fh;
{
register struct Window *win;
register struct MsgPort *user;
struct IntuiMessage *msg;
REGISTER ULONG i,j,len,Pos;
UBYTE Buffer[10];
ClearMenuStrip(WindowPtr);
Titel=WindowPtr->Title;
win=CreateStdWindow("Übertragung",75,100,150,24+BorderHeight(),CLOSEWINDOW|GADGETUP|VANILLAKEY,
WINDOWCLOSE|WINDOWDEPTH|WINDOWDRAG|ACTIVATE|GIMMEZEROZERO);
if(win!=NULL)
{
SetFont(win->RPort,GetOpalFont());
CreateBoolGadget(win,10,5,120,12,"Stop!");
user=win->UserPort;
j=0;
len=Seek(fh,0,OFFSET_END);
len=Seek(fh,0,OFFSET_BEGINNING);
do
{
sprintf(&ARexxTitel,
"ATKeyboard - [Übertragung -> %ld%%, %ld Bytes]",
(DivU32(MulU32(j,100),len)),j);
SetWindowTitles(WindowPtr,&ARexxTitel,TitelText);
i=Read(fh,&Buffer,10);
for(Pos=0;Pos<i;Pos++)
{
SendeZeichen(Buffer[Pos]);
j++;
}
msg=GetMsg(user);
if(msg!=NULL)
{
ReplyMsg(msg);
i=0;
}
}
while(i!=0);
Close(fh);
DeleteStdWindow(win);
}
else
{
Requester("Kein Speicher für Stop-Fenster","","Okay",NULL);
}
SetMenuStrip(WindowPtr,&Menu1);
SetWindowTitles(WindowPtr,Titel,TitelText);
}
/* Clip-Header lesen */
LONG TeilKopfLesen()
{
UBYTE KopfDaten[8];
LONG *NettoDaten;
ClipReq->io_Data=&KopfDaten;
ClipReq->io_Length=8;
ClipReq->io_Command=CMD_READ;
DoIO(ClipReq);
NettoDaten=&KopfDaten[4];
return(*NettoDaten);
}
/* Testen, ob überhaupt ein Clip vorliegt */
BOOL ClipVorhanden()
{
BOOL ClipOkay;
if(CheckIO(ClipReq))
{
ClipOkay=(ClipReq->io_ClipID >= 0);
Remove(ClipReq);
}
else
{
Delay(20);
if(CheckIO(ClipReq))
{
ClipOkay=(ClipReq->io_ClipID >= 0);
Remove(ClipReq);
}
else
{
AbortIO(ClipReq);
ClipOkay=FALSE;
}
}
return(ClipOkay);
}
/* Clip-Kopf lesen */
LONG ClipKopfLesen()
{
UBYTE KopfDaten[12];
ClipReq->io_ClipID=0;
ClipReq->io_Command=CMD_READ;
ClipReq->io_Offset=0;
ClipReq->io_Data=&KopfDaten;
ClipReq->io_Length=12;
SendIO(ClipReq);
if(ClipVorhanden())
return(TeilKopfLesen());
else
return(NULL);
}
/* Clip aus Clipboard an PC senden */
VOID SendeClip()
{
register struct Window *win;
register struct MsgPort *user;
struct IntuiMessage *msg;
REGISTER ULONG j,len,Pos;
REGISTER BOOL ende;
UBYTE Buffer[16];
ClipReq->io_Length=ClipKopfLesen();
if(ClipReq->io_Length)
{
ClearMenuStrip(WindowPtr);
Titel=WindowPtr->Title;
win=CreateStdWindow("Übertragung",75,100,150,24+BorderHeight(),CLOSEWINDOW|GADGETUP|VANILLAKEY,
WINDOWCLOSE|WINDOWDEPTH|WINDOWDRAG|ACTIVATE|GIMMEZEROZERO);
if(win!=NULL)
{
SetFont(win->RPort,GetOpalFont());
CreateBoolGadget(win,10,5,120,12,"Stop!");
user=win->UserPort;
ClipReq->io_Data=&Buffer;
ClipReq->io_Length=16;
DoIO(ClipReq);
ende=FALSE; j=0;
while((ClipReq->io_Actual>0)&&(ende==FALSE))
{
sprintf(&ARexxTitel,
"ATKeyboard - [Übertragung -> %ld Bytes]",j);
SetWindowTitles(WindowPtr,&ARexxTitel,TitelText);
for(Pos=0;Pos<ClipReq->io_Actual;Pos++)
{
SendeZeichen(Buffer[Pos]);
j++;
}
msg=GetMsg(user);
if(msg!=NULL)
{
ReplyMsg(msg);
ende=TRUE;
}
ClipReq->io_Data=&Buffer;
ClipReq->io_Length=16;
DoIO(ClipReq);
}
DeleteStdWindow(win);
}
else
{
Requester("Kein Speicher für Stop-Fenster","","Okay",NULL);
}
ClipReq->io_Data=NULL;
ClipReq->io_Length=1024;
while(ClipReq->io_Actual>0)
DoIO(ClipReq);
SetMenuStrip(WindowPtr,&Menu1);
SetWindowTitles(WindowPtr,Titel,TitelText);
}
}